home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr48 / pasclern.zip / SUBRANGE.PAS < prev    next >
Pascal/Delphi Source File  |  1993-04-01  |  1KB  |  44 lines

  1. PROGRAM scaler_operations;
  2.  
  3. TYPE days = (mon,tue,wed,thu,fri,sat,sun);
  4.      work = mon..fri;
  5.      rest = sat..sun;
  6.  
  7. VAR  day      : days; (* This is any day of the week *)
  8.      workday  : work; (* These are the the working days *)
  9.      weekend  : rest; (* The two weekend days only *)
  10.      index    : 1..12;
  11.      alphabet : 'a'..'z';
  12.      start    : 'a'..'e';
  13.  
  14. BEGIN  (* main program *)
  15. (*  The following statements are commented out because they contain
  16.     various errors that will halt compilation.
  17.  
  18.   workday := sat;   sat is not part of workday's subrange.
  19.   rest := fri;      fri is not part of weekend's subrange.
  20.   index := 13;      index is only allowed to go up to 12,
  21.   index := -1;        and down to 1.
  22.   alphabet := 'A'   alphabet, as defined, includes only the
  23.                       lower case alphabet.
  24.   start := 'h'      h is not in the first five letters.
  25.  
  26.   End of commented out section.  *)
  27.  
  28. workday := tue;
  29. weekend := sat;
  30. day := workday;
  31. day := weekend;
  32. index := 3+2*2;
  33. start := 'd';
  34. alphabet := start;
  35.                           (* since alphabet is "d"    *)
  36. start := succ(alphabet);  (* start will be 'e'        *)
  37. start := pred(alphabet);  (* start will be 'c'        *)
  38. day := wed;
  39. day := succ(day);  (* day will now be 'thu' *)
  40. day := succ(day);  (* day will now be 'fri' *)
  41. index := ord(day); (* index will be 4 (fri = 4) *)
  42.  
  43. END. (* of main program *)
  44.